package com.gagakuai.test;

/*
 * @program: settement
 * @description:
 * @author: houhong
 * @create: 2022-11-27 13:40
 */
public class CompletedFutureDemo {

    public static void main(String[] args) throws InterruptedException {

        MoneyServiceImpl MoneyServiceImpl=new MoneyServiceImpl();
        MoneyServiceImpl.addMoney(100).whenComplete((result,exc)->{
            if (exc == null) {
                System.out.println("结果为"+result);
            } else {
                System.out.println("发生异常"+exc);
            }
        });

        System.out.println("主线程执行结束");
        //这里是为了暂缓让主线程退出，让结果可以打印出来
        Thread.sleep(30000);

    }

}